package cube.io.file;

import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;

/**
 * 文件输出流处理
 * 
 * @author abiao
 */
public abstract class FileOutputHandler extends
        FileHandler<FileOutputStream, Void> {

    public FileOutputHandler(String fileName) {
        super(fileName);
    }

    protected FileOutputStream init(String fileName, boolean append) {
        FileOutputStream fos = null;
        try {
            fos = new FileOutputStream(fileName, append);
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        }
        return fos;
    }

    protected Void write(FileOutputStream fos, final byte[] data)
            throws IOException {
        fos.write(data);
        fos.flush();
        return null;
    }
}
